package persistency.reader;

/**
 * StudentReader.java
 * Purpose: this class represents a course that students can take
 * 
 * @author Hans Brems
 * @version 1.0 05/11/2011
 */

import java.util.ArrayList;

import model.RetrainingStudent;

public class RetrainingStudentReader extends ContentReader {
	
	/** Constructs a course reader object **/
	public RetrainingStudentReader() {
	}
	
	/** Constructs a retraining student reader object */
	public RetrainingStudentReader(String filePath) {
		super(filePath);
	}
	
	/** Reads a text file containing retraining student objects into a collection */
	public ArrayList<RetrainingStudent> read() {
		
		// Create list
		ArrayList<RetrainingStudent> retrainingStudents = new ArrayList<RetrainingStudent>();
		
		// Skip the first line (header)
		this.scanner.nextLine();

		// Construct a course object from each line
		while (this.scanner.hasNext()) {
			
			// Create a new retraining student
			RetrainingStudent retrainingStudent = new RetrainingStudent();
			
			// Set course values
			retrainingStudent.setStudentNumber(this.scanner.next());
			retrainingStudent.setHighestDegree(this.scanner.next());
			retrainingStudent.setRetrainingReason(this.scanner.next());
			
			// Add course to collection
			retrainingStudents.add(retrainingStudent);
		}
		
		// Return list
		return retrainingStudents;
	}
}